// MGC
//
// QSAppDelegate+BasicSetting.m
// HYDDoctor
//
// Created by MGC on 2017/10/23.
// Copyright © 2017年 MGC. All rights reserved.
//
// @ description <#描述#> 

#import "QSAppDelegate+BasicSetting.h"

#import <IQKeyboardManager.h>

@implementation QSAppDelegate (BasicSetting)
/**
 *  设置根控制器
 */
- (void)setupRootViewController
{
    self.window = [[UIWindow alloc] initWithFrame:kScreenBounds];
    self.window.backgroundColor = kWhite_color;
    [self.window makeKeyAndVisible];
}

/**
 *  设置键盘
 */
- (void)setUpKeyboard
{
    IQKeyboardManager *manager = [IQKeyboardManager sharedManager];
    manager.enable = YES;
    manager.shouldResignOnTouchOutside = YES;
    manager.shouldToolbarUsesTextFieldTintColor = YES;
    manager.enableAutoToolbar = YES;
}

/**
 *  配置https证书
 */
- (void)setUpHttpsWithFileName:(NSString *)cerFile
{
    NSString *cerPath = [[NSBundle mainBundle] pathForResource:cerFile ofType:nil];
    NSData * certData =[NSData dataWithContentsOfFile:cerPath];
    NSSet * certSet = [[NSSet alloc] initWithObjects:certData, nil];
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/html"];
    
    manager.requestSerializer = [AFHTTPRequestSerializer serializer];
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    
    AFSecurityPolicy * policy = [AFSecurityPolicy policyWithPinningMode:AFSSLPinningModeCertificate withPinnedCertificates:certSet];
    policy.allowInvalidCertificates = NO;
    [manager setSecurityPolicy:policy];
}

/**
 *  设置状态栏
 */
- (void)setupStateBarStytle:(UIStatusBarStyle)statusBarStyle
{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
    
    [[UIApplication sharedApplication] setStatusBarStyle:statusBarStyle animated:NO];
    // 启动时隐藏状态栏
    [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationFade];
#pragma clang diagnostic pop
}

@end
